{
LANG : PASCAL
PROB : cowtour
}

program COWTOUR;
const
  fi = 'cowtour.in';
  fo = 'cowtour.out';
  max = 150;
  oo = 10000000000;
type
  point = record
            x, y : longint;
          end;
var
  a : array[1..max, 1..max] of byte;
  d : array[1..max, 1..max] of extended;
  m : array[1..max] of integer;
  g : array[1..max] of byte;
  p : array[1..max] of point;
  maximum : array[1..max+1] of extended;
  best : extended;
  n, ngroup : integer;

procedure inp;
var
  i, j : integer;
  c : char;
begin
  read(n);
  for i := 1 to n do
    with p[i] do read(x, y);
  readln;
  for i := 1 to n do
  begin
    for j := 1 to n do
    begin
      read(c);
      a[i, j] := ord(c) - 48;
    end;
    readln;
  end;
end;

function dis(p1, p2 : point) : extended;
begin
  dis := sqrt(sqr(p1.x - p2.x) + sqr(p1.y - p2.y));
end;

procedure creat_d;
var
  i, j : integer;
begin
  for i := 1 to n do
    for j := 1 to n do
      if i = j then d[i, j] := 0
      else d[i, j] := oo;
  for i := 1 to n do
    for j := i+1 to n do
      if a[i, j] = 1 then
      begin
        d[i, j] := dis(p[i], p[j]);
        d[j, i] := d[i, j];
      end;
end;

procedure floyd;
var
  i, j, k : integer;
begin
  for k := 1 to n do
    for i := 1 to n do
      for j := i+1 to n do
        if d[i, j] > d[i, k] + d[k, j] then
        begin
          d[i, j] := d[i, k] + d[k, j];
          d[j, i] := d[i, j];
        end;
end;

procedure creat_m;
var
  i, j : integer;
  temp : extended;
begin
  for i := 1 to n do
  begin
    temp := -oo;
    for j := 1 to n do
      if (d[i, j] < oo) and (d[i, j] > temp) then
      begin
        temp := d[i, j];
        m[i] := j;
      end;
  end;
end;

procedure creat_g;
var
  i, j : integer;
begin
  ngroup := 0;
  fillchar(g, sizeof(g), 0);
  for i := 1 to n do
    if g[i] = 0 then
    begin
      inc(ngroup);
      for j := 1 to n do
        if (g[j] = 0) and (d[i, j] < oo) then g[j] := ngroup;
    end;
end;

procedure init;
begin
  creat_d;
  floyd;
  creat_m;
  creat_g;
end;

procedure process;
var
  i, j , k : integer;
  temp : extended;
begin
  fillchar(maximum, sizeof(maximum), 0);
  for i := 1 to n do
  begin
    k := g[i];
    if maximum[k] < d[i, m[i]] then maximum[k] := d[i, m[i]];
  end;
  maximum[151] := oo;
  for i := 1 to n do
    for j := i+1 to n do
      if g[i] <> g[j] then
      begin
        temp := d[i, m[i]] + d[j, m[j]] + dis(p[i], p[j]);
        if maximum[151] > temp then maximum[151] := temp;
      end;
end;

procedure out;
var
  i : integer;
begin
  best := maximum[151];
  for i := 1 to ngroup do
    if best < maximum[i] then best := maximum[i];
  writeln(best:0:6);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  out;
  close(output);
  close(input);
end.
